import {request,RequestConfig,HttpRequestMethod,LengyuHttpResponse,download,upload, PageRequestParam}  from '../utils/request'

export interface ReservationDto {
  id?:string,
  applyName?:string,
  applyPhone?:string,
  applyIdCard?:string,
  applyCompany?:string,
  carNo?:string,
  visitCount?:number,
  visitName?:string,
  visitPhone?:string,
  visitReason?:string,
  confirmId?:string,
  confirmName?:string,
  status?:number,
  startTimeStr?:string,
  endTimeStr?:string,
  startDateStr?:string,
  endDateStr?:string,
  beizhu?:string,
  createId?:string,
  createTime?:Date,
  updateId?:string,
  updateTime?:Date,
}


export function save(reservation:any): Promise<LengyuHttpResponse> {
  console.log("创建访客记录");

  let requestConfig:RequestConfig={
    url:'reservation/save',
    method:HttpRequestMethod.POST,
    data:reservation,
    token:true
  }
  return request(requestConfig);
}

export function confirm(id:any,status:number): Promise<LengyuHttpResponse> {
  console.log("确认访客记录");
  let reservation:ReservationDto = {
    id:id,
    status:status
  }
  let requestConfig:RequestConfig={
    url:'reservation/confirm',
    method:HttpRequestMethod.POST,
    data:reservation,
    token:true
  }
  return request(requestConfig);
}

export function page(status:any,pageIndex:number,pageSize:number): Promise<LengyuHttpResponse> {
  console.log("获取历史信息列表");
  let paramMapObj = {
    status:status,
  }
  let param = {
    pageIndex:pageIndex,
    pageSize:pageSize,
    paramMapObj:paramMapObj
  }

  let requestConfig:RequestConfig={
    url:'reservation/page',
    method:HttpRequestMethod.POST,
    data:param,
    token:true
  }
  return request(requestConfig);
}

export function getCurrentReservation(): Promise<LengyuHttpResponse> {
  console.log("获取当前正在进行的拜访");

  let requestConfig:RequestConfig={
    url:'reservation/getCurrentReservation',
    method:HttpRequestMethod.POST,
    token:true
  }
  return request(requestConfig);
}